package com.lhf.aicloud.entity;

import lombok.Builder;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @author : lhf
 * @date : Created in 2024/07/30
 * @description: Security 用户认证对象
 */
@Data
public class SecurityUserDetails implements UserDetails {

    private String username;
    private String password;
    private Long uid;

    public SecurityUserDetails(Long uid, String username, String password){
        this.uid = uid;
        this.username = username;
        this.password = password;
    }

    /**
     * 存放权限的集合
     */
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    /**
     * 获取密码
     */
    @Override
    public String getPassword() {
        return this.password;
    }

    /**
     * 获取用户名
     */
    @Override
    public String getUsername() {
        return this.username;
    }

    /**
     * 账户是否未过期
     */
    @Override
    public boolean isAccountNonExpired() {
        return UserDetails.super.isAccountNonExpired();
    }

    /**
     * 账户是否未锁定
     */
    @Override
    public boolean isAccountNonLocked() {
        return UserDetails.super.isAccountNonLocked();
    }

    /**
     * 凭证是否未过期
     */
    @Override
    public boolean isCredentialsNonExpired() {
        return UserDetails.super.isCredentialsNonExpired();
    }

    /**
     * 账户是否可用
     */
    @Override
    public boolean isEnabled() {
        return UserDetails.super.isEnabled();
    }
}
